import { createRouter, createWebHashHistory } from "vue-router";
import BaseLayout from '@/view/layouts/Index.vue'

export const constantRoutes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/view/login/index.vue'),
    meta: {
      hidden: true,
      title: "登入"
    },
  }
]

export const asyncRoutes = [
  {
    path: '/',
    name: 'system',
    redirect: { name: 'dictionary' },
    component: markRaw(BaseLayout),
    meta: {
      title: "系统管理",
      code: 'RBAC'
    },
    children: [
      {
        name: 'project',
        path: 'project',
        component: () => import('@/view/system/project/index.vue'),
        meta: {
          title: "项目管理",
          code: "RBAC_PROJECT"
        },
      },
      {
        name: 'dictionary',
        path: 'dictionary',
        component: () => import('@/view/system/dictionary/index.vue'),
        meta: {
          title: "字典管理",
          code: "RBAC_DICT"
        },
      },
      {
        name: 'tentant',
        path: 'tentant',
        component: () => import('@/view/system/tentant/index.vue'),
        meta: {
          title: "租户管理",
          code: "RBAC_TENTANT"
        },
      },
      {
        name: 'user',
        path: 'user',
        component: () => import('@/view/system/user/index.vue'),
        meta: {
          title: "用户管理",
          code: "RBAC_USER"
        },
      },
      {
        name: 'role',
        path: 'role',
        component: () => import('@/view/system/role/index.vue'),
        meta: {
          title: "角色管理",
          code: "RBAC_ROLE"
        },
      },
      {
        name: 'resource',
        path: 'resource',
        component: () => import('@/view/system/resource/index.vue'),
        meta: {
          title: "资源管理",
          code: "RBAC_RESOURCE"
        },
      },
      {
        name: 'datalog',
        path: 'datalog',
        component: () => import('@/view/system/datalog/index.vue'),
        meta: {
          title: "临时数据管理",
          code: "RBAC_DATALOG"
        },
      }
    ]
  },
  {
    path: '/spider',
    name: 'spider',
    redirect: 'spiderSubscribe',
    component: markRaw(BaseLayout),
    meta: {
      title: "爬虫管理"
    },
    children: [
      {
        name: 'spiderSubscribe',
        path: 'subscribe',
        component: () => import('@/view/spider/subscribe/index.vue'),
        meta: {
          title: '订阅管理'
        },
      }
    ]
  },
  {
    path: '/zhongyi',
    name: 'zhongyi',
    redirect: 'zhongyitag',
    component: markRaw(BaseLayout),
    meta: {
      title: "中医管理",
      code: "ZHONGYI"
    },
    children: [
      {
        name: 'zhongyitag',
        path: 'zhongyitag',
        component: () => import('@/view/zhongyi/tag/index.vue'),
        meta: {
          title: '分类管理',
          code: "ZY_FL"
        },
      },
      {
        name: 'yaocai',
        path: 'yaocai',
        component: () => import('@/view/zhongyi/yaocai/index.vue'),
        meta: {
          title: '药材管理',
          code: "ZY_YC"
        },
      },
      {
        name: 'fangji',
        path: 'fangji',
        component: () => import('@/view/zhongyi/fangji/index.vue'),
        meta: {
          title: '方剂管理',
          code: "ZY_FJ"
        },
      },
      {
        name: 'examimination_category',
        path: 'examimination/category',
        component: () => import('@/view/zhongyi/examination/category.vue'),
        meta: {
          title: '试卷分类管理',
          code: "ZY_SJFL"
        },
      },
      {
        name: 'examination',
        path: 'examination',
        component: () => import('@/view/zhongyi/examination/examination.vue'),
        meta: {
          title: '试卷管理',
          code: "ZY_SJ"
        },
      }
    ]
  },
  {
    path: '/photo',
    name: 'photo',
    redirect: 'photolist',
    component: markRaw(BaseLayout),
    meta: {
      title: "图片管理"
    },
    children: [
      {
        name: 'photolist',
        path: 'photolist',
        component: () => import('@/view/photo/home/index.vue'),
        meta: {
          title: '图片列表'
        },
      }
    ]
  },
  {
    path: '/about',
    name: 'about',
    component: () => import('@/view/HelloWorld.vue'),
    meta: {
      title: "关于"
    },
  },
]


const router = createRouter({
  history: createWebHashHistory(),
  routes: constantRoutes,
})


export default router;